class Solution
{
public:
    int minimumBuckets(string hamsters)
    {
        int n = hamsters.size();
        int minBucketCount = 0;
        int lastBucket = -2;
        for (int i = 0; i < n; ++i)
        {
            if (hamsters[i] == 'H')
            {
                if (lastBucket == i - 1)
                {
                    continue;
                }
                else if (i < n && hamsters[i + 1] == '.')
                {
                    ++minBucketCount;
                    lastBucket = i + 1;
                }
                else if (i >= 1 && hamsters[i - 1] == '.')
                {
                    ++minBucketCount;
                    lastBucket = i - 1;
                }
                else
                {
                    return -1;
                }
            }
        }
        return minBucketCount;
    }
};